<template>
  <ContentWrap
    class="mb-0!"
    :class="[
      footer
        ? '!h-[calc(100vh-var(--top-tool-height)-var(--tags-view-height)-var(--app-footer-height)-10px)]'
        : '!h-[calc(100vh-var(--top-tool-height)-var(--tags-view-height)-20px)]'
    ]"
    :bodyStyle="{ height: '100%', padding: '10px' }"
  >
    <div class="flex flex-col !h-full justify-between">
      <div class="flex">
        <slot name="tool"></slot>
      </div>
      <el-divider border-style="dashed" class="m-y-0!" />
      <el-scrollbar viewClass="flex-grow mt-10px">
        <el-row class="mx-0px!"
          ><el-col
            :xs="24"
            :sm="24"
            :md="24"
            :lg="24"
            :xl="24"
            v-for="(item, index) in list"
            :key="index"
          >
            <CartItem :item="item" class="mb-10px! cursor-pointer">
              <template #extInfo>
                <div class="custom-text-16 color-[var(--el-color-primary)]">
                  <!-- {{ filterCardPeriod(item.assets) }} -->
                  {{ item.leftStatus }} &nbsp;&nbsp;{{ item.enableStatus }}
                </div>
              </template>

              <template #itemButton>
                <div class="h-full! flex flex-col justify-between p-y-5px">
                  <div class="!w-full flex justify-end">
                    <el-button link type="danger" @click.stop="handleDelete(item)">
                      <Icon icon="ep:delete" :size="24" />
                    </el-button>
                  </div>
                  <!-- 如果是正常卡项服务输入次数 -->

                  <el-input-number
                    class="meton-input-number w-120px!"
                    disabled
                    v-model="item.count"
                    @click.stop="() => {}"
                    :min="1"
                    @change="
                      (val: number) => {
                        handleChangeNumber(item, val)
                      }
                    "
                  />

                  <div class="!w-full flex justify-end"> &nbsp; </div>
                </div>
              </template>
            </CartItem>
            <el-divider class="my-10px!" border-style="dashed" />
          </el-col>
        </el-row>
      </el-scrollbar>

      <div class="flex justify-end">
        <slot name="bottom"></slot>
      </div>
    </div>
  </ContentWrap>
</template>
<script lang="ts" setup>
import { propTypes } from '@/utils/propTypes'
import { useAppStore } from '@/store/modules/app'
const appStore = useAppStore()
const footer = computed(() => appStore.getFooter)
/** 员工选择 */
import SystemUserShowcase from '@/views/shop/components/system/user/systemUserShowcase.vue'

const emit = defineEmits([
  'handleChangeNumber',
  'handleReplaceCard',
  'handleChange',
  'handleDelete',
  'handelEdit'
])
defineOptions({ name: 'CartList' })
defineProps({
  // 列表
  list: propTypes.arrayOf(propTypes.object).def([]),
  replaceList: propTypes.arrayOf(propTypes.object).def([]),
  rebateType: propTypes.number
})
import CartItem from './CartItem.vue'
import CartReplaceItem from './CartReplaceItem.vue'

const handleDelete = (item: any) => {
  emit('handleDelete', item)
}

const handleChangeNumber = (item: any, value: number) => {
  emit('handleChangeNumber', item, value)
}
const handleReplaceCheck = (item: any) => {
  emit('handleReplaceCard', item)
}
const handleChange = (item: any) => {
  emit('handleChange', item)
} //监听数量变化
const handelChangeEmployee = (item: any) => {
  emit('handelEdit', 'setEmployee', item)
}
</script>
<style lang="scss">
.meton-input-number {
  .el-input {
    font-size: 16px;
  }
  .el-input__inner {
    font-weight: bold;
  }
}
</style>
